<?php
class Lottery_reseller_model extends BZ_Model
{
    protected $table   = 'lottery_reseller';

    /**
     * 查找 抽奖的关联账号
     */
    public function findByLotteryId($lotteryId)
    {
        $this->db->select('id, reseller_uid, reseller_name');
        $this->db->from($this->table);
        $this->db->where('lottery_id', $lotteryId);

        return $this->db->get();
    }

    /**
     * 批量添加
     */
    public function insertBatch($lotteryId, $postDate){
        $data = array();
        foreach ($postDate as $key=>$value){
            $data[] = array(
                'lottery_id'    => $lotteryId,
                'reseller_uid'  => $key,
                'reseller_name' => $value
            );
        }
        return $this->db->insert_batch($this->table, $data);
    }

    /**
     * [delete description]
     */
    public function delete($lotteryId)
    {
        $this->db->where('lottery_id', $lotteryId);
        return $this->db->delete($this->table);
    }
}